package com.caishi.lkx.exam.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.caishi.lkx.exam.model.HotSharedModel;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface HotShareMapper extends BaseMapper<HotSharedModel> {
    //    @Select("SELECT ts.id, ts.title, ts.content, ts.order, ts.delete, ts.create_time, ts.update_time, COUNT(tsu.user_id) AS view_count " +
//            "FROM two_share ts " +
//            "LEFT JOIN two_share_user tsu ON ts.id = tsu.share_id " +
//            "WHERE ts.delete = 0 " +
//            "GROUP BY ts.id, ts.title, ts.content, ts.order, ts.delete, ts.create_time, ts.update_time " +
//            "ORDER BY view_count DESC, ts.order DESC " +
//            "LIMIT 10")
    @Select("SELECT ts.id, ts.title, ts.content, ts.order, ts.delete, ts.create_time, ts.update_time, COUNT(tsu.user_id) AS view_count " +
            "FROM two_share ts " +
            "LEFT JOIN two_share_user tsu ON ts.id = tsu.share_id " +
            "WHERE ts.delete = 0 " +
            "GROUP BY ts.id " +
            "ORDER BY ts.create_time DESC " +
            "LIMIT 10")
    List<HotSharedModel> getHotSharedList();
}


//SELECT ts.id, ts.title, ts.content, ts.order, ts.delete, ts.create_time, ts.update_time, COUNT(tsu.user_id) AS view_count FROM two_share ts LEFT JOIN two_share_user tsu ON ts.id = tsu.share_id WHERE ts.delete = 0 ORDER BY ts.create_time LIMIT 10

//SELECT ts.id, ts.title, ts.content, ts.order, ts.delete, ts.create_time, ts.update_time, COUNT(tsu.user_id) AS view_count FROM two_share ts LEFT JOIN two_share_user tsu ON ts.id = tsu.share_id WHERE ts.delete = 0 GROUP BY ts.id ORDER BY ts.create_time DESC LIMIT 10